package cn.tedu.gxtt.passport.controller;

import cn.tedu.gxtt.commons.pojo.user.dto.UserLoginDTO;
import cn.tedu.gxtt.commons.restful.JsonResult;
import cn.tedu.gxtt.passport.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/users", produces = "application/json; charset=utf-8")
public class UserController {

    @Autowired
    private IUserService userService;

    // 以下是测试访问的请求
    @GetMapping("/hello")
    public String sayHello() {
        return "hello~~~";
    }

    // http://localhost:8080/users/login?username=xiaoming&password=123456
    @RequestMapping("/login")
    public JsonResult<String> login(UserLoginDTO userLoginDTO) {
        String jwt = userService.login(userLoginDTO );
        return JsonResult.ok(jwt);
    }

}
